package com.example.demo.order;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @PostMapping("/create")
    public String createOrder() {
        // 模拟创建订单
        String orderId = "ORDER_" + System.currentTimeMillis();
        // 发送消息到主题"ORDER_CREATED"
        //rocketMQTemplate.convertAndSend("ORDER_CREATED", orderId);
        return "Order created: " + orderId;
    }
}
